home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / EXT / A-E / AutoCruise.cpt / AutoCruise ƒ / AutoCruise (Source) / Init.c < prev    next >
C/C++ Source or Header  |  1989-10-07  |  2KB  |  70 lines

  1. /* Init.c */
  2. /*
  3.  * The init resource that installs the patch for the AutoCruise Mouse.
  4.  * Be sure to set the attributes bits so this INIT resource is locked.
  5.  * INIT 31 fails to do this for us.
  6.  */
  7.  
  8. #include "Cruise.h"
  9.  
  10. static    crsrTaskVarsP varsAddress;
  11. static    long          scratch;
  12.  
  13. main()
  14.     {
  15.     
  16.     asm        /* Real men do it in assembly.        */
  17.         {
  18.         clr.l        DeskHook            /* Why? Because DTS says so.    */
  19.         move.l        #sizeof(crsrTaskVars),d0
  20.         _NewPtr        SYS+CLEAR
  21.         
  22.         move.l        a0,varsAddress        /* remember where it is for later */
  23.         move.l        jCrsrTask,OFFSET(crsrTaskVars,OldCrsrTask)(a0) /* save old task */
  24.         }
  25.         
  26.     scratch=(long)GetResource('COOL',128);
  27.     DetachResource(scratch);
  28.     
  29.     /* 
  30.      * init variables.  This prevents the cursor from jumping wildly
  31.      * around the screen at bootup.  It isn't strictly necessary, but it
  32.      * doesn't hurt.
  33.      */
  34.     
  35.     varsAddress->Prevh=(Mouse.h)<<3;
  36.     varsAddress->Prevv=(Mouse.v)<<3;
  37.     varsAddress->PrevInth=Mouse.h;
  38.     varsAddress->PrevIntv=Mouse.v;
  39.     varsAddress->LastTimeh=Ticks;
  40.     varsAddress->LastTimev=Ticks;
  41.     
  42.     /*
  43.      * Slightly specialized stuff.  Basically, we install the patch
  44.      * by modifing some zero page globals.
  45.      */
  46.     asm
  47.         {
  48.         move.l        scratch,a0    /* get saved handle */
  49.         move.l        (a0),a0        /* deref handle */
  50.  
  51.         move.l        varsAddress,(a0)    /* tell patch where to find its vars */
  52.         addq.l        #4,a0
  53.         move.l        a0,jCrsrTask        /* tell system about patch */
  54.         }
  55.         
  56.     }
  57.  
  58. /*
  59.  * Notice than an application or cdev can check to see if this patch
  60.  * is installed by the following neat trick:
  61.  *
  62.  * Pointer    *aPtr;
  63.  *
  64.  * aPtr=(Pointer *)jCrsrTask;
  65.  * aPtr--;         *** remember, '--' (of a pointer pointer) -> '-=4' ***
  66.  * if (GetPointerSize(*aPtr)==sizeof(crsrTaskVars))
  67.  *    { It's installed }
  68.  * else
  69.  *  { It's not installed }
  70.  */